import {request} from "./request";
import * as url from "url";

export function getDetail(iid){
  return request({
    url:'/detail',
    params:{
      iid
    }
  })
}

// 用于获取商品的信息，并封装成一个对象
export class Goods {
  constructor(itemInfo,columns,services) {
    this.title=itemInfo.title;
    this.desc=itemInfo.desc;
    this.newPrice=itemInfo.price;
    this.oldPrice=itemInfo.oldPrice;
    this.discount=itemInfo.discountDesc;
    this.columns=columns;
    this.services=services;
    this.realPrice=itemInfo.lowNowPrice;
  }
}

export class Shop {
  constructor(shopInfo) {
    this.logo=shopInfo.shopLogo;
    this.name=shopInfo.name;
    this.fans=shopInfo.cFans;
    this.sells=shopInfo.cSells;
    this.score=shopInfo.score;
    this.goodsCount=shopInfo.cGoods;
  }
}

// 封装商品的参数详情
export class GoodsParam {
  constructor(info,rule) {
    // images并不是每个商品都有的
    this.image=info.images ? info.images[0] : '';
    this.infos=info.set;
    this.sizes=rule.tables;
  }
}

// 获取商品的推荐信息
export function getRecommend(){
  return request({
    url:'/recommend'
  })
}
